<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
	<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

<script type="text/javascript" src="/resource/js/jquery-3.2.1/jquery.js"></script>
<link href="/resource/bootstrap-4.3.1/css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="/resource/bootstrap-4.3.1/js/bootstrap.js"></script>

<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="add" method="post">
		学生姓名:<input type="text" name="name"><br><br>
		日期:<input type="date" name="enterDate"><br><br>
		选修课:<c:forEach items="${subjectlist}" var="a">
			<input type="checkbox" value="${a.id }" name="subjectId"> ${a.name }
		</c:forEach><br><br>
		
		省份:<select name="provinceId" id="provinceId" onchange="changePro()">
			<option value="1">请选择</option>
			<c:forEach items="${listArea }" var="province">
				<option value="${province.id }">${province.name}</option>
			</c:forEach>
		</select>
		市:<select name="cityId" id="cityId" onclick="changeCit()"></select>
		县:<select name="countryId" id="countryId"></select><br><br>
		<input type="submit" value="添加">
	</form>
</body>
<script type="text/javascript">
	function changePro(){
		var id=$("#provinceId").val()
		$.post("/getArea",{id:id},function(data){
			$("#cityId").empty();
			for (var i = 0; i < data.length; i++) {
				$("#cityId").append('<option value="'+data[i].id+'">'+data[i].name+'</option>')
			}
		},"json")
	}
	function changeCit(){
		var id=$("#cityId").val()
		$.post("/getArea",{id:id},function(data){
			$("#countryId").empty();
			for (var i = 0; i < data.length; i++) {
				$("#countryId").append('<option value="'+data[i].id+'">'+data[i].name+'</option>')
			}
		},"json")
	}
	
</script>
</html>